package com.spider.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Lisy on 2018/10/9.
 */
public class BUtil {

    /*从字符串中提取av编号信息*/
    public static String getAVCode(String originalString){

        Pattern avPattern = Pattern.compile("av[0-9]*");
        Matcher avMatcher = avPattern.matcher(originalString);
        avMatcher.find();
        String avCode = avMatcher.group(0);
        return avCode;
    }

    public static Integer getCount(String originalString){
        Integer count = null;
        try {
            if (originalString.contains("万")) {
                Double doubleCount = Double.parseDouble(originalString.replace("万", "")) * 10000;
                count = doubleCount.intValue();
            } else {
                count = Integer.parseInt(originalString);
            }
        } catch (Exception e) {
            count = -1;
        }
        return count;
    }

}
